<template>
	<view class="login-page">
		<view style="text-align: center;margin-top: 50px;">
			<img style="width: 88px;height: 88px;" :src="logoUrl" alt="">
		</view>
		<view style="text-align: center;margin-top: 20px;font-size: 32rpx;font-weight: 600;">昆山高新区篮球协会</view>
		<view style="margin-top: 60px;margin-top: 65px;padding: 0 45px;">
			<view>
				<!-- <input class="input-sty" type="text" v-model.trim="loginObj.userNm" placeholder="姓名"> -->
				账号：<input maxlength="11" class="input-sty" type="text" v-model.trim="loginObj.phone"
					placeholder="请输入账号">
			</view>
			<view style="margin-top: 30px;position: relative;">
				密码：<input maxlength="10" class="input-sty" :type="fla == 0?'password':'text'"
					v-model.trim="loginObj.password" placeholder="初始密码为手机后六位">
				<uni-icons class="see-sty" v-show="fla == 1" @click="seePassword(0)"
					type="eye-slash-filled"></uni-icons>
				<!-- <uni-icons class="see-sty" v-show="fla == 0" @click="seePassword(1)" type="eye-filled"></uni-icons> -->
			</view>
			<view style="margin: 30px auto 10px;width: 150px;text-align: center;" @click="loginBtn">
				<view class="btn-sty" style="background: #fc993b;color:#fff;">登入</view>
			</view>
			<view style="width: 150px;margin: 0 auto;text-align: center;" @click="regBtn">
				<view class="btn-sty">注册</view>
			</view>
		</view>
		<view style="font-size: 12px;color:#F87C7C;margin-top: 50px;padding: 0 45px;">
			注：本小程序为昆山市高新区篮球协会的球队注册系统，需注册为会员后才能享有查看球队信息，球员信息，赛事预告，精彩回放，篮球培训等信息。
		</view>
		<view class="turn-down-btn" @click="backHome">
			<view style="background: red;color:#fff;font-size: 12px;">拒绝</view>
		</view>
	</view>
</template>

<script>
	import {
		cheackUser,
		verifyForm
	} from '@/utils/baseFn.js';

	export default {
		data() {
			return {
				loginObj: {
					// userNm: '',
					phone: '',
					password: ''
				},
				logoUrl: '',
				fla: 0
			}
		},
		created() {},
		onLoad() {
			this.logoUrl = `${this.$projectImg}logo.png`
		},
		mounted() {},
		methods: {
			seePassword(fla) {
				this.fla = fla
			},
			loginBtn() {
				if (!verifyForm(this.loginObj)) return
				const parm = {
					phone: this.loginObj.phone,
					password: this.loginObj.password
				}
				cheackUser(parm, 'login').then(res => {
					console.log(res)
					if (res.fla) {
						uni.setStorage({
							key: 'userInfo',
							data: res.data || {},
							success: function() {
								console.log('success');
								uni.getStorage({
									key: 'userInfo',
									success: function(res) {
										console.log(res.data)
									}
								})
							}
						})
						uni.showModal({
							content: '登入成功',
							showCancel: false,
							success: function(e) {
								// uni.navigateBack({
								// 	delta:1
								// })
								uni.switchTab({
									url: '../home/home'
								});
							}
						})
					} else {
						let data = null
						if (res.data && res.data.userStatus == 2) {
							data = {
								...res.data
							}
							res.data = '申请被驳回'
						}
						uni.showModal({
							content: res.data || '未注册，请先注册！',
							showCancel: false,
							success: function(r) {
								if (r.confirm) {
									if (res.data == '申请被驳回') {
										uni.navigateTo({
											url: `../register/playRegister?parm=${JSON.stringify(data)}`
										});
									}
								}
							}
						})
					}
				})
			},
			regBtn() {
				uni.navigateTo({
					url: '../register/register'
				});
			},
			backHome() {
				uni.switchTab({
					url: '../home/home'
				});
			}
		}
	}
</script>

<style>
	.login-page {}

	.input-sty {
		font: 28rpx;
		border-bottom: 1px solid #dcdfe6;
		display: inline-block;
		width: 80%;
		vertical-align: bottom;
	}

	.btn-sty {
		width: 150px;
		height: 38px;
		color: #fc993b;
		background: #ffffff;
		border: 1px solid #fc993b;
		border-radius: 20px;
		line-height: 38px;
	}

	.see-sty {
		position: absolute;
		right: -25px;
		top: 0;
	}
	.turn-down-btn {
		width: 50px;height: 28px;text-align: center;line-height: 28px;float: right;margin-right: 45px;
	}
</style>
<style lang="scss">
</style>